import { requestClient } from '#/api/request';

export namespace DemoTableApi {
  export interface PageFetchParams {
    [key: string]: any;
    page: number;
    pageSize: number;
  }
  export interface addParams {
    username: string;
    password: string;
    realName: string;
    roles: string[];
  }

  export interface updateParams {
    id: string;
    username: string;
    password: string;
    realName: string;
    roles: string[];
  }

  export interface deleteParams {
    id: string;
  }
}

/**
 * 获取示例表格数据
 */
async function getUserListApi(params: DemoTableApi.PageFetchParams) {
  return requestClient.get('/admin/list', { params });
}

async function addUserApi(data: DemoTableApi.addParams) {
  return requestClient.post('/admin/list', data);
}

async function updateUserApi(data: DemoTableApi.updateParams) {
  return requestClient.put('/admin/list', data);
}

async function deleteUserApi(params: DemoTableApi.deleteParams) {
  return requestClient.delete('/admin/list', { params });
}

export { addUserApi, deleteUserApi, getUserListApi, updateUserApi };
